import 'package:flutter/cupertino.dart';
import 'package:mobile_app.core/core/presentation/theme/theme.dart';

class TileTextField extends StatelessWidget {
  const TileTextField({
    required this.autocorrect,
    required this.enableSuggestions,
    this.controller,
    this.focusNode,
    this.placeholder,
    this.onSubmitted,
    this.textInputAction,
    this.keyboardType,
    this.maxLines = 1,
    super.key,
  });

  final bool autocorrect;
  final bool enableSuggestions;
  final TextEditingController? controller;
  final FocusNode? focusNode;
  final String? placeholder;
  final VoidCallback? onSubmitted;
  final TextInputAction? textInputAction;
  final TextInputType? keyboardType;
  final int? maxLines;

  @override
  Widget build(BuildContext context) {
    return CupertinoTextField(
      style: CoreTheme.of(context).textTheme.tileTitle,
      controller: controller,
      focusNode: focusNode,
      autofocus: false,
      autocorrect: autocorrect,
      enableSuggestions: enableSuggestions,
      maxLines: maxLines,
      keyboardType: keyboardType,
      keyboardAppearance: CoreTheme.of(context).brightness,
      cursorColor: CoreTheme.of(context).primaryColor,
      padding: const EdgeInsets.symmetric(
        vertical: 13.5,
        horizontal: 16,
      ),
      placeholder: placeholder,
      placeholderStyle: CoreTheme.of(context).textTheme.tileTitle.copyWith(
            color: CoreTheme.of(context).tilePlaceholderColor,
          ),
      decoration: BoxDecoration(
        color: CoreTheme.of(context).tileColor,
      ),
      textInputAction: textInputAction,
      onSubmitted: (_) {
        onSubmitted?.call();
      },
    );
  }
}
